package com.tengju.user.infrastructure.repository.star.convert;

import com.tengju.user.domain.model.star.StarIndicator;
import com.tengju.user.domain.model.star.StarIndicatorType;
import com.tengju.user.domain.model.user.UserIdCode;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.StarIndicatorStatDO;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class StarIndicatorConvert {

    public static StarIndicator convertToModel(StarIndicatorStatDO starIndicatorStatDO) {

        LocalDate indicatorDay = LocalDate.parse(starIndicatorStatDO.getIndicatorDay().toString(), DateTimeFormatter.ofPattern("yyyyMMdd"));

        return new StarIndicator(
                new UserIdCode(starIndicatorStatDO.getIdCode()),
                StarIndicatorType.fromVal(starIndicatorStatDO.getIndicatorCode()),
                starIndicatorStatDO.getIndicatorValue(),
                null,
                indicatorDay
        );
    }

}
